home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 3: Developer Tools / Linux Cubed Series 3 - Developer Tools.iso / utils / console / svgatext.3 / svgatext / SVGATextMode-1.3 / XFREE / patches / ET4000_gendac.patch < prev    next >
Encoding:
Text File  |  1995-10-29  |  7.6 KB  |  358 lines

  1. diff -p /home/kmg/xtemp/xc/programs/Xserver/hw/xfree86/common_hw/S3gendac.c common_hw/S3gendac.c
  2. *** /home/kmg/xtemp/xc/programs/Xserver/hw/xfree86/common_hw/S3gendac.c    Sat Jul  1 11:49:02 1995
  3. --- common_hw/S3gendac.c    Sun Oct 29 18:07:20 1995
  4. ***************
  5. *** 11,19 ****
  6.   #include "xf86_OSlib.h"
  7.   #include <math.h>
  8.   
  9.   extern int vgaIOBase;
  10.   
  11. ! static void setdacpll(
  12.   #if NeedFunctionPrototypes
  13.   int reg, unsigned char data1, unsigned char data2
  14.   #endif
  15. --- 11,25 ----
  16.   #include "xf86_OSlib.h"
  17.   #include <math.h>
  18.   
  19. + #define PLL_S3GENDAC      1
  20. + #define PLL_S3TRIO        2
  21. + #define PLL_ET4000GENDAC  8
  22.   extern int vgaIOBase;
  23.   
  24. ! static void setS3gendacpll(
  25.   #if NeedFunctionPrototypes
  26.   int reg, unsigned char data1, unsigned char data2
  27.   #endif
  28. *************** int reg, unsigned char data1, unsigned c
  29. *** 25,34 ****
  30.   #endif
  31.   );
  32.   
  33.   static int commonSetClock( 
  34.   #if NeedFunctionPrototypes
  35.      long freq, int clock,
  36. !    int min_n2, int trio_pll,
  37.      long freq_min, long freq_max
  38.   #endif
  39.   );     
  40. --- 31,47 ----
  41.   #endif
  42.   );
  43.   
  44. + static void setET4000gendacpll(
  45. + #if NeedFunctionPrototypes
  46. + int reg, unsigned char data1, unsigned char data2
  47. + #endif
  48. + );
  49.   static int commonSetClock( 
  50.   #if NeedFunctionPrototypes
  51.      long freq, int clock,
  52. !    int min_n2, int pll_type,
  53.      long freq_min, long freq_max
  54.   #endif
  55.   );     
  56. *************** S3gendacSetClock(freq, clk)
  57. *** 38,44 ****
  58.   long freq;
  59.   int clk;
  60.   {
  61. !    return commonSetClock(freq, clk, 0, 0, 100000, 250000);
  62.   }
  63.   
  64.   int
  65. --- 51,73 ----
  66.   long freq;
  67.   int clk;
  68.   {
  69. !    return commonSetClock(freq, clk, 0, PLL_S3GENDAC, 100000, 250000);
  70. ! }
  71. ! int
  72. ! ET4000gendacSetClock(freq, clk)
  73. ! long freq;
  74. ! int clk;
  75. ! {
  76. !    return commonSetClock(freq, clk, 0, PLL_ET4000GENDAC, 100000, 270000);
  77. ! }
  78. ! int
  79. ! ET4000gendacSetpixmuxClock(freq, clk)
  80. ! long freq;
  81. ! int clk;
  82. ! {
  83. !    return commonSetClock(freq, clk, 2, PLL_ET4000GENDAC, 100000, 270000);
  84.   }
  85.   
  86.   int
  87. *************** ICS5342SetClock(freq, clk)
  88. *** 46,52 ****
  89.   long freq;
  90.   int clk;
  91.   {
  92. !    return commonSetClock(freq, clk, 1, 0, 100000, 250000);
  93.   }
  94.   
  95.   int
  96. --- 75,81 ----
  97.   long freq;
  98.   int clk;
  99.   {
  100. !    return commonSetClock(freq, clk, 1, PLL_S3GENDAC, 100000, 250000);
  101.   }
  102.   
  103.   int
  104. *************** S3TrioSetClock(freq, clk)
  105. *** 54,73 ****
  106.   long freq;
  107.   int clk;
  108.   {
  109. !    return commonSetClock(freq, clk, 0, 1, 135000, 270000);
  110.   }
  111.   
  112. ! static int
  113. ! commonSetClock(freq, clk, min_n2, trio_pll, freq_min, freq_max)
  114.   long freq;
  115. ! int clk;
  116. ! int min_n2, trio_pll;
  117.   long freq_min, freq_max;
  118.   {
  119.      double ffreq, ffreq_min, ffreq_max;
  120.      double div, diff, best_diff;
  121.      unsigned int m;
  122. !    unsigned char n, n1, n2;
  123.      unsigned char best_n1=16+2, best_n2=2, best_m=125+2;
  124.   
  125.      ffreq     = freq     / 1000.0 / BASE_FREQ;
  126. --- 83,102 ----
  127.   long freq;
  128.   int clk;
  129.   {
  130. !    return commonSetClock(freq, clk, 0, PLL_S3TRIO, 135000, 270000);
  131.   }
  132.   
  133. ! void
  134. ! commonCalcClock(freq, min_n2, freq_min, freq_max, mdiv, ndiv)
  135.   long freq;
  136. ! int min_n2;
  137.   long freq_min, freq_max;
  138. + unsigned char *mdiv, *ndiv;
  139.   {
  140.      double ffreq, ffreq_min, ffreq_max;
  141.      double div, diff, best_diff;
  142.      unsigned int m;
  143. !    unsigned char n1, n2;
  144.      unsigned char best_n1=16+2, best_n2=2, best_m=125+2;
  145.   
  146.      ffreq     = freq     / 1000.0 / BASE_FREQ;
  147. *************** long freq_min, freq_max;
  148. *** 117,139 ****
  149.         );
  150.   #endif
  151.   
  152. !    n = (best_n1 - 2) | (best_n2 << 5);
  153. !    m = best_m - 2;
  154.   
  155. -    if (trio_pll)
  156. -       settriopll(clk, m, n);
  157. -    else
  158. -       setdacpll(clk, m, n);
  159.   
  160. !    return 0;
  161.   }       
  162.   
  163.   
  164.   static void
  165.   #if NeedFunctionPrototypes
  166. ! setdacpll(int reg, unsigned char data1, unsigned char data2)
  167.   #else
  168. ! setdacpll(reg, data1, data2)
  169.   int reg;
  170.   unsigned char data1;
  171.   unsigned char data2;
  172. --- 146,192 ----
  173.         );
  174.   #endif
  175.   
  176. !    *ndiv = (best_n1 - 2) | (best_n2 << 5);
  177. !    *mdiv = best_m - 2;
  178. ! }       
  179.   
  180.   
  181. ! static int
  182. ! commonSetClock(freq, clk, min_n2, pll_type, freq_min, freq_max)
  183. ! long freq;
  184. ! int clk;
  185. ! int min_n2, pll_type;
  186. ! long freq_min, freq_max;
  187. ! {
  188. !    unsigned char m, n;
  189. !    commonCalcClock(freq, min_n2, freq_min, freq_max, &m, &n);
  190. !    switch(pll_type)
  191. !    {
  192. !      case PLL_S3GENDAC:
  193. !          setS3gendacpll(clk, m, n);
  194. !          break;
  195. !      case PLL_S3TRIO:
  196. !          settriopll(clk, m, n);
  197. !          break;
  198. !      case PLL_ET4000GENDAC:
  199. !          setET4000gendacpll(clk, m, n);
  200. !          break;
  201. !      default: 
  202. !          ErrorF("Internal error: unknown pll_type in S3gendac.c");
  203. !          return -1;
  204. !     }
  205. !      return 0;
  206.   }       
  207. +   
  208.   
  209.   
  210.   static void
  211.   #if NeedFunctionPrototypes
  212. ! setS3gendacpll(int reg, unsigned char data1, unsigned char data2)
  213.   #else
  214. ! setS3gendacpll(reg, data1, data2)
  215.   int reg;
  216.   unsigned char data1;
  217.   unsigned char data2;
  218. *************** unsigned char data2;
  219. *** 147,152 ****
  220. --- 200,235 ----
  221.      outb(vgaCRIndex, 0x55);
  222.      tmp = inb(vgaCRReg) & 0xFC;
  223.      outb(vgaCRReg, tmp | 0x01);  
  224. +    tmp1 = inb(GENDAC_INDEX);
  225. +    outb(GENDAC_INDEX, reg);
  226. +    outb(GENDAC_DATA, data1);
  227. +    outb(GENDAC_DATA, data2);
  228. +    /* Now clean up our mess */
  229. +    outb(GENDAC_INDEX, tmp1);  
  230. +    outb(vgaCRReg, tmp);
  231. + }
  232. + static void
  233. + #if NeedFunctionPrototypes
  234. + setET4000gendacpll(int reg, unsigned char data1, unsigned char data2)
  235. + #else
  236. + setET4000gendacpll(reg, data1, data2)
  237. + int reg;
  238. + unsigned char data1;
  239. + unsigned char data2;
  240. + #endif
  241. + {
  242. +    unsigned char tmp, tmp1;
  243. +    int vgaCRIndex = vgaIOBase + 4;
  244. +    int vgaCRReg = vgaIOBase + 5;
  245. +         
  246. +    /* set RS2 via CR31 */
  247. +    outb(vgaCRIndex, 0x31);
  248. +    tmp = inb(vgaCRReg) & 0xBF;
  249. +    outb(vgaCRReg, tmp | 0x40);  
  250.      tmp1 = inb(GENDAC_INDEX);
  251.   
  252.      outb(GENDAC_INDEX, reg);
  253. diff -p /home/kmg/xtemp/xc/programs/Xserver/hw/xfree86/common_hw/S3gendac.h common_hw/S3gendac.h
  254. *** /home/kmg/xtemp/xc/programs/Xserver/hw/xfree86/common_hw/S3gendac.h    Fri Jan 20 05:21:21 1995
  255. --- common_hw/S3gendac.h    Sun Oct 29 18:08:39 1995
  256. *************** int S3gendacSetClock( 
  257. *** 12,17 ****
  258. --- 12,29 ----
  259.   #endif
  260.   );     
  261.   
  262. + int ET4000gendacSetClock( 
  263. + #if NeedFunctionPrototypes
  264. +    long freq, int clock
  265. + #endif
  266. + );     
  267. + int ET4000gendacSetpixmuxClock( 
  268. + #if NeedFunctionPrototypes
  269. +    long freq, int clock
  270. + #endif
  271. + );     
  272.   int ICS5342SetClock( 
  273.   #if NeedFunctionPrototypes
  274.      long freq, int clock
  275. *************** int S3TrioSetClock( 
  276. *** 23,25 ****
  277. --- 35,47 ----
  278.      long freq, int clock
  279.   #endif
  280.   );     
  281. + void commonCalcClock(
  282. + #if NeedFunctionPrototypes
  283. +    long freq,
  284. +    int min_n2,
  285. +    long freq_min, long freq_max,
  286. +    unsigned char *mdiv, unsigned char *ndiv
  287. + #endif
  288. + );
  289. diff -p /home/kmg/xtemp/xc/programs/Xserver/hw/xfree86/common_hw/xf86_HWlib.h common_hw/xf86_HWlib.h
  290. *** /home/kmg/xtemp/xc/programs/Xserver/hw/xfree86/common_hw/xf86_HWlib.h    Sat Jul  1 11:49:08 1995
  291. --- common_hw/xf86_HWlib.h    Sun Oct 29 17:28:26 1995
  292. *************** extern int S3gendacSetClock(
  293. *** 151,156 ****
  294. --- 151,172 ----
  295.   #endif
  296.   );
  297.   
  298. + extern int ET4000gendacSetClock( 
  299. + #if NeedFunctionPrototypes
  300. +         long,
  301. +         int
  302. + #endif
  303. + );     
  304. + extern int ET4000gendacSetpixmuxClock( 
  305. + #if NeedFunctionPrototypes
  306. +         long,
  307. +         int
  308. + #endif
  309. + );     
  310.   extern int ICS5342SetClock(
  311.   #if NeedFunctionPrototypes
  312.       long,
  313. *************** extern void s3IBMRGB_Init(
  314. *** 263,268 ****
  315. --- 279,299 ----
  316.       void
  317.   #endif
  318.   );
  319. + /*
  320. +  * Gendac clock calculator: needed for those that want to get
  321. +  * clock params without actually programming them (e.g. W32 driver)
  322. +  */
  323. + extern int commonCalcClock(
  324. + #if NeedFunctionPrototypes
  325. +    long,
  326. +    int,
  327. +    long, long,
  328. +    unsigned char *,
  329. +    unsigned char *
  330. + #endif
  331. + );
  332.   
  333.   _XFUNCPROTOEND
  334.   
  335.